package com.cpkso.buss.backend.trade.web;

import javax.servlet.http.HttpSession;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cpkso.buss.backend.trade.service.TbOrderService;
import com.cpkso.buss.backend.trade.vo.ActualFee;
import com.cpkso.buss.backend.trade.vo.StatisticsConditionVo;
import com.runze.base.web.BaseController;
import com.runze.base.web.Query;
import com.runze.base.web.Response;

/**
 * @author wrzhxy@qq.com
 * @date 2018年5月13日
 * 
 * 业绩统计
 */
@RestController
@RequestMapping("/money")
public class StatsticsController extends BaseController {
	@RequiresPermissions("tbOrder:queryAll")
	@GetMapping("/slave")
	public Response statstics(@ModelAttribute StatisticsConditionVo scv) {
		return tbOrderService.statistics(scv);
	}
	
	@RequiresPermissions("tbOrder:query")
	@GetMapping("/yours")
	public Response myself(@ModelAttribute StatisticsConditionVo scv, HttpSession session) {
		Long userId = (Long) session.getAttribute("user");
		scv.setUserId(userId);
		scv.setUsername(null);
		return tbOrderService.statistics(scv);
	}
	@RequiresPermissions("tbOrder:queryAll")
	@GetMapping("/notips")
	public Response notips(@ModelAttribute Query query) {
		return tbOrderService.notips(query);
	}
	// TODO 应为tbOrder:update
	@RequiresPermissions("tbOrder:query")
	@PutMapping("/fee")
	public Response updatePrice(@ModelAttribute ActualFee fee) {
		tbOrderService.updatePrice(fee);
		return success();
	}
	@Autowired
	private TbOrderService tbOrderService;
}
